package org.firebug.common.tools.core;

/**
 * @Author: 张晓东
 */
public final class ComparableTools {
    public static <T> boolean eq(Comparable<T> a, Comparable<T> b) {
        return a.compareTo((T) b) == 0;
    }

    public static <T> boolean gt(Comparable<T> a, Comparable<T> b) {
        return a.compareTo((T) b) == 1;
    }

    public static <T> boolean gte(Comparable<T> a, Comparable<T> b) {
        return a.compareTo((T) b) != -1;
    }

    public static <T> boolean lt(Comparable<T> a, Comparable<T> b) {
        return a.compareTo((T) b) == -1;
    }

    public static <T> boolean lte(Comparable<T> a, Comparable<T> b) {
        return a.compareTo((T) b) != 1;
    }

    public static <T> Comparable<T> min(Comparable<T> a, Comparable<T> b) {
        return lt(a, b) ? a : b;
    }

    public static <T> Comparable<T> max(Comparable<T> a, Comparable<T> b) {
        return gt(a, b) ? a : b;
    }

    private ComparableTools() {
    }
}
